console.log('cli run')
const inquirer = require('inquirer');
const ejs = require('ejs');
const fs = require('fs');
const path = require('path');
inquirer.prompt([{
  type: 'input',
  name: 'projName',
  message: 'input the project name',
  default: 'default'
},
  {
    type: 'list',
    name: 'projType',
    message: 'choose the type of your project',
    choices: ['mobile', 'pc'],
    default: 'mobile'
  }])
  .then(answers => {
    const tmpDir = path.join(__dirname, './templates');
    fs.readdir(tmpDir, (err, files) => {
      if (err) throw err;
      files.forEach(file => {
        console.log(path.join(tmpDir, file));
        ejs.renderFile(path.join(tmpDir, file), answers, (err, renderResult) => {
          fs.writeFileSync(path.join(process.cwd(),file),renderResult);
        })
      })
    })
  }).catch(e => {
  console.log(e)
})